package nan.logicalcontrol;

import java.util.Scanner;

public class Main {
    /*
    判断num是否为素数
     */
    public static void main18(String[] args) {
        Scanner scan=new Scanner(System.in);
        int num= scan.nextInt();
        int i=2;
        for(;i<num;i++) {     //num=8
            if (num % i == 0) {
                System.out.println(num+"不是素数");
                break;
            }
        }
        if(i==num){
            if(i == 2){
                System.out.println(num+"既不是素数也不是质数");
            }else {
                System.out.println(num+"是素数");
            }
        }
    }
    public static void main17(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n= scan.nextInt();
        System.out.println(n);
        //String str=scan.nextLine();//nextLine遇到回车就会结束
        String str=scan.next();
        System.out.println(str);
    }
    public static void main16(String[] args) {
        Scanner scan=new Scanner(System.in);
        String str =scan.nextLine();
        System.out.println(str);//读取字符串
        /*
        String str=scan.next();//读取字符串，遇到空格就结束
        System.out.println(str);
         */
    }
    /*
     求1！+2！+3!+4!+5!
     */
    public static void main8(String[] args) {
        int sum=0;
        //int num=5;
        //先用外for循环控制数字由1到5，再用内for循环把1！+2！+3！+4！+5！加在一起
        for( int j=1;j<=5;j++) {//用j控制1、2、3、4、5
            int result = 1;
            for (int i = 1; i <= j; i++) {
                result *= i;//分别计算1！、2！、3！、4!、5！
            }
            sum += result;//将1！、2！、3！、4!、5！加在一起
        }
        System.out.println(sum);
    }
    public static void main14(String[] args) {
        for(int i=1;i<=10;i++)
        System.out.println(i+" ");
    }
    public static void main13(String[] args) {
        int u=1;
        while(u <= 10){
            if(u%3 != 0){
                u++;
                continue;//结束本趟循环
            }
            System.out.println(u);
            u++;
        }
    }
    public static void main12(String[] args) {
        int u=1;
        while(u<=10){
            if(u%3==0){
                System.out.println(u);
                break;//结束所有循环
            }
            u++;
        }
    }
    /*
    求1！+2！+3!+4!+5!
     */
    public static void main11(String[] args) {
        int num=1;int sum=0;int ret=1;int a=1;
        while(num<=5){
            while(a<=num){
                ret*=a;
                a++;
            }
            sum+=ret;
            num++;
        }
        System.out.println(sum);
    }
    public static void main10(String[] args) {
        int num=1,ret=1,a=1,sum=0;
        while(num<=5) {
            ret *= a;
            a++;
            num++;
            sum = sum + ret;
        }
        System.out.println(sum);
    }
    /*
    阶乘
    */
    public static void main9(String[] args) {
        int num=5,a=1;
        int ret=1;
        while(a<=num){
            ret*=a;
            a++;
        }
        System.out.println(ret);
    }
    /*
    计算1-100之间奇数的和
    计算1-100之间偶数的和；
    计算1-100的和；
    while循环
     */
    public static void main(String[] args) {
        int n=1;
        int sum=0,sum1=0,sum2=0;
        while (n<=100){
            if(n%2!=0){
                sum=sum+n;
            }else{
                sum1=sum1+n;
            }
            n++;
            sum2=sum1+sum;
            }
        System.out.println(sum);//奇数
        System.out.println(sum1);//偶数
        System.out.println(sum2);
        }
    public static void main7(String[] args) {
        int num=10;
        while (num>0){
            System.out.println(num+" ");
            num--;
        }
    }
    public static void main6(String[] args) {
        int a=20;
        //short a=1;
        switch (a){
            case 1:
                System.out.println("1");
                break;
                case 2:
                    System.out.println("2");
                    break;
                default:
                    System.out.println("既不是1也不是2");
                    break;
            }
        }
    /*
    判断是否是闰年
     */
    public static void main5(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        if(a%4==0 && a%100!=0){
            System.out.println(a+"是闰年");
        }else{
            System.out.println(a+"不是闰年");
        }
    }
    /*
    判断一个数字是正数还是负数
     */
    public static void main4(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        if(a>0) {
            System.out.println(a+"是正数");
        }else if (a<0){
            System.out.println(a+"是负数");
        }else{
            System.out.println(a+"既不是正数也不是负数");
        }
    }
    public static void main3(String[] args) {
        //int a=900087;
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        if(a % 2==0){
            System.out.println(a+"是偶数");
        }else {
            System.out.println(a+"是奇数");
        }
    }
    public static void main2(String[] args) {
        int a=10;
        if(a == 20){
            System.out.println("abc");
        } else if(a==5){
            System.out.println("123");
        }else {
            System.out.println("dui");
        }
    }
    public static void main1(String[] args) {
        System.out.println("aa");
        System.out.println("bb");
    }
}
